/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.address;

import junit.framework.TestCase;

import java.text.ParseException;

/**
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public class TelURLImplTest extends TestCase {
    public TelURLImplTest(String name) {
        super(name);
    }

    public void testSimpleCreation() {
        TelURLImpl url = new TelURLImpl();
        assertEquals("The scheme is wrong!", "tel", url.getScheme());
        assertNull("The parameter isub must be null!", url.getIsdnSubAddress());
        assertNull("The parameter phone-context must be null!", url.getPhoneContext());
        assertNull("The parameter phone-number must be null!", url.getPhoneNumber());
        assertNull("The parameter post-dial must be null!", url.getPostDial());
    }

    public void testCreation() {
        TelURLImpl url = new TelURLImpl("+79165556677");
        assertEquals("The scheme is wrong!", "tel", url.getScheme());
        assertTrue("The URI should be global!", url.isGlobal());
        assertEquals("The phone number is wrong!", "79165556677", url.getPhoneNumber());
    }

    public void testToString() {
        TelURLImpl url = new TelURLImpl("115");
        try {
            url.setPhoneContext("7807900");
        } catch (ParseException e) {
            fail(e.getMessage());
        }
        assertEquals("The string form of the URL is wrong!", "tel:115;phone-context=7807900", url.toString());
    }

    public void testLazyCreation() {
        TelURLImpl url = TelURLImpl.createLazily("tel:115;postd=001;phone-context=+74957807900");
        assertEquals("The post-dial sequence is wrong!", "001", url.getPostDial());
        assertEquals("The phone context is wrong!", "+74957807900", url.getPhoneContext());
        assertEquals("The phone number is wrong!", "115", url.getPhoneNumber());
        assertEquals("The scheme is wrong!", "tel", url.getScheme());
    }
}
/*
 * $Log$
 */